/*
 * Copyright (C) 2014 Realtek Semiconductor Corp.
 * All Rights Reserved.
 *
 * This program is the proprietary software of Realtek Semiconductor
 * Corporation and/or its licensors, and only be used, duplicated,
 * modified or distributed under the authorized license from Realtek.
 *
 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
 *
 */


#include "app_basic.h"

MIB_TABLE_INFO_T gMibRTPPseudowireParametersTableInfo;
MIB_ATTR_INFO_T  gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ATTR_NUM];
MIB_TABLE_RTPPSEUDOWIREPARAMETERS_T gMibRTPPseudowireParametersDefRow;
MIB_TABLE_OPER_T gMibRTPPseudowireParametersOper;

GOS_ERROR_CODE RTPPseudowireParametersDrvCfg(void* pOldRow, void* pNewRow, MIB_OPERA_TYPE operationType, MIB_ATTRS_SET attrSet, UINT32 pri)
{
    OMCI_LOG(OMCI_LOG_LEVEL_DBG, "Start %s...", __FUNCTION__);

    switch (operationType){
    case MIB_ADD:
    	OMCI_LOG(OMCI_LOG_LEVEL_DBG,"RTPPseudowireParameters --> ADD");
    	break;
    case MIB_SET:
    	OMCI_LOG(OMCI_LOG_LEVEL_DBG,"RTPPseudowireParameters --> SET");
    	break;
    case MIB_GET:
    	OMCI_LOG(OMCI_LOG_LEVEL_DBG,"RTPPseudowireParameters --> GET");
    	break;
    case MIB_DEL:
    	OMCI_LOG(OMCI_LOG_LEVEL_DBG,"RTPPseudowireParameters --> DEL");
    	break;
    default:
    	return GOS_FAIL;
    	break;
    }

    return GOS_OK;
}
GOS_ERROR_CODE mibTable_init(MIB_TABLE_INDEX tableId)
{
    gMibRTPPseudowireParametersTableInfo.Name = "RTPPseudowireParameters";
    gMibRTPPseudowireParametersTableInfo.ShortName = "RTPPP";
    gMibRTPPseudowireParametersTableInfo.Desc = "RTP pseudowire parameters";
    gMibRTPPseudowireParametersTableInfo.ClassId = (UINT32)(OMCI_ME_CLASS_RTP_PSEUDOWIRE_PARAMETERS);
    gMibRTPPseudowireParametersTableInfo.InitType = (UINT32)(OMCI_ME_INIT_TYPE_OLT);
    gMibRTPPseudowireParametersTableInfo.StdType = (UINT32)(OMCI_ME_TYPE_STANDARD);
    gMibRTPPseudowireParametersTableInfo.ActionType = (UINT32)(OMCI_ME_ACTION_CREATE | OMCI_ME_ACTION_DELETE | OMCI_ME_ACTION_SET | OMCI_ME_ACTION_GET);
    gMibRTPPseudowireParametersTableInfo.pAttributes = &(gMibRTPPseudowireParametersAttrInfo[0]);

    gMibRTPPseudowireParametersTableInfo.attrNum = MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ATTR_NUM;
    gMibRTPPseudowireParametersTableInfo.entrySize = sizeof(MIB_TABLE_RTPPSEUDOWIREPARAMETERS_T);
    gMibRTPPseudowireParametersTableInfo.pDefaultRow = &gMibRTPPseudowireParametersDefRow;

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Name = "EntityId";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "ClockReference";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "RTPTimeStampMode";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "PTYPE";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].Name = "SSRC";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "ExpectedPTYPE";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].Name = "ExpectedSSRC";

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Entity ID";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Clock reference";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "RTP time stamp mode";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "PTYPE";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "SSRC";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Expected PTYPE";
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Expected SSRC";

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].Len = 8;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].Len = 8;

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = TRUE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_SBC;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;

    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_CLOCKREFERENCE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_RTPTIMESTAMPMODE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_PTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_SSRC_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDPTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibRTPPseudowireParametersAttrInfo[MIB_TABLE_RTPPSEUDOWIREPARAMETERS_EXPECTEDSSRC_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;

    gMibRTPPseudowireParametersDefRow.EntityId = 0;
    gMibRTPPseudowireParametersDefRow.ClockReference = 1;
    gMibRTPPseudowireParametersDefRow.RTPTimeStampMode = 0;
    gMibRTPPseudowireParametersDefRow.PTYPE = 0;
    gMibRTPPseudowireParametersDefRow.SSRC = 0;
    gMibRTPPseudowireParametersDefRow.ExpectedPTYPE = 0;
    gMibRTPPseudowireParametersDefRow.ExpectedSSRC = 0;

    memset(&gMibRTPPseudowireParametersOper, 0x0, sizeof(MIB_TABLE_OPER_T));
    gMibRTPPseudowireParametersOper.meOperDrvCfg = RTPPseudowireParametersDrvCfg;
    gMibRTPPseudowireParametersOper.meOperConnCheck = NULL;
    gMibRTPPseudowireParametersOper.meOperDump = omci_mib_oper_dump_default_handler;
    gMibRTPPseudowireParametersOper.meOperConnCfg = NULL;
    gMibRTPPseudowireParametersOper.meOperAvlTreeAdd = NULL;
    gMibRTPPseudowireParametersOper.meOperAlarmHandler = NULL;
    gMibRTPPseudowireParametersOper.meOperTestHandler = NULL;

    MIB_TABLE_RTPPSEUDOWIREPARAMETERS_INDEX = tableId;
    MIB_InfoRegister(tableId, &gMibRTPPseudowireParametersTableInfo, &gMibRTPPseudowireParametersOper);
    MIB_RegisterCallback(tableId, NULL, NULL);

    return GOS_OK;
}

